using System;
using System.Collections.Generic;
using System.Text;

namespace Typing_GUI.CLASS
{
    public class CChiTietLuyenTap
    {
        
    #region"thuoc tinh"
        private int mabaitap;

        public int Mabaitap
        {
            get { return mabaitap; }
            set { mabaitap = value; }
        }
        private int maluyentap;

        public int Maluyentap
        {
            get { return maluyentap; }
            set { maluyentap = value; }
        }
    #endregion
    #region"phuong thuc"
        public bool createUnit()
        {
            string sql = "insert into ChiTietLuyenTap(MaLuyenTap,MaBaiTap) values(";
            sql += this.maluyentap.ToString() + "," + this.mabaitap.ToString()+")";
            if (!DataProvider.ExecuteNonQuery(sql))
                return false;
            return true;
        }

        public bool deleteUnit(int id)
        {
            string sql = "delete from ChiTietLuyenTap where MaBaiTap=" + id.ToString();
            if (!DataProvider.ExecuteNonQuery(sql))
                return false;
            return true;
        }

        public bool updateUnitMaLuyenTap()
        {
            string sql = "update ChiTietLuyenTap set MaBaiTap=" + this.mabaitap.ToString();
            sql += " where MaLuyenTap=" + this.Maluyentap.ToString();
            if (!DataProvider.ExecuteNonQuery(sql))
                return false;
            return true;
        }

        public bool updateUnitMaBaiTap()
        {
            string sql = "update ChiTietLuyenTap set MaLuyenTap=" + this.maluyentap.ToString();
            sql += " where MaBaiTap=" + this.Mabaitap.ToString();
            if (!DataProvider.ExecuteNonQuery(sql))
                return false;
            return true;
        }

        ///vinh
        public bool XoaChiTiet1LuyenTap()
        {
            string sql = "";
            sql += " Delete From ChiTietLuyenTap ";
            sql += " Where MaLuyenTap= " + maluyentap;
            sql += " and MaBaiTap =" + mabaitap;
            bool kq=DataProvider.ExecuteNonQuery(sql);
            return kq;
        }
        // vinh 
    #endregion

    }
}
